home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmigaPlus / Begleitmaterial / 50Tools / Grafik / PerfectPaint / rexx / box / 3DGrid.rx next >
Text File  |  2001-05-05  |  7KB  |  450 lines

  1. /* Box arexx */
  2.  
  3.     options results
  4.   parse ARG Port x1 y1 x2 y2 b
  5.     ADDRESS value Port
  6.  
  7.     pp_CountFrames
  8.     Total_Frame=result
  9.     if Total_Frame=0 then Total_Frame=1
  10.     Start_Frame=1
  11.     End_Frame=Total_Frame
  12.  
  13.     IF x1>x2 then DO
  14.         X=x1;x1=x2;x2=X
  15.     END
  16.  
  17.     IF y1>y2 then DO
  18.         Y=y1;y1=y2;y2=Y
  19.     END
  20.  
  21.     Bw=(x2-x1)+1
  22.     Bh=(y2-y1)+1
  23.  
  24.     Cx=x1+Bw/2
  25.     Cy=y1+Bh/2
  26.         
  27.     R=-1
  28.     Path=0;Type=0
  29.     Anim=0
  30.  
  31.     Start_Shearx=5
  32.     Start_Sheary=5
  33.     Start_rotx=0
  34.     Start_roty=0
  35.     Start_rotz=0
  36.     Start_size=100
  37.     Start_O=100
  38.  
  39.     End_Shearx=5
  40.     End_Sheary=5
  41.     End_rotx=0
  42.     End_roty=0
  43.     End_rotz=0
  44.     End_size=100
  45.     End_O=100
  46.  
  47. DO UNTIL R>-1
  48.  
  49.     pp_DialogInit 250 245 "*3DGrid*" 11
  50.     pp_Cycle 10 70 5 100 16 "Animation" 1 "No|Yes" Anim
  51.     pp_Cycle 0 70 30 100 16 "Path" 1 "None|Left|Right|Up|Down" Path
  52.     pp_Cycle 1 70 48 100 16 "Type" 1 "In|Out" Type
  53.     pp_Button 2 20 66 200 16 '*Frame*(*#'||Start_Frame||'->#'||End_Frame||'*)*'
  54.  
  55.     pp_Integer 3 56 91 60 16 'Line' 0 Start_Shearx
  56.     pp_Integer 4 156 91 60 16 'Row' 0 Start_Sheary
  57.  
  58.     pp_Button 5 20 116 200 16 '*Rot*X*(*'||Start_rotx||'*->*'||End_rotx||'*)*'
  59.     pp_Button 6 20 134 200 16 '*Rot*Y*(*'||Start_roty||'*->*'||End_roty||'*)*'
  60.     pp_Button 7 20 152 200 16 '*Rot*Z*(*'||Start_rotz||'*->*'||End_rotz||'*)*'
  61.  
  62.     pp_Button 8 20 175 200 16 '*Size*%*(*'||Start_size||'*->*'||End_size||'*)*'
  63.     pp_Button 9 20 193 200 16 '*Opacity*(*'||Start_O||'*->*'||End_O||'*)*'    
  64.  
  65.     pp_Dialog
  66.     R=result
  67.  
  68.     pp_GetDialog 10
  69.     Anim=Result
  70.  
  71.     pp_GetDialog 0
  72.     Path=result
  73.  
  74.     pp_GetDialog 1
  75.     Type=result
  76.  
  77.     pp_GetDialog 3
  78.     Start_Shearx=result
  79.  
  80.     pp_GetDialog 4
  81.     Start_Sheary=result
  82.  
  83.     if R=-9 then DO
  84.     if Anim=1 then DO
  85.         pp_DialogInit 150 80 "*OPACITY*" 2
  86.             pp_Integer 0 60 5 50 16 "Start" 1 Start_O
  87.             pp_Integer 1 60 25 50 16 "End" 1 End_O
  88.         pp_Dialog
  89.         rc=result
  90.         IF rc=1 then DO
  91.             pp_GetDialog 0
  92.             Start_O=result
  93.             pp_GetDialog 1
  94.             End_O=result        
  95.         END            
  96.     END
  97.     ELSE DO
  98.         pp_DialogInit 150 55 "*OPACITY*" 1
  99.         pp_Integer 0 75 5 50 16 "Opacity" 1 Start_O
  100.         pp_Dialog
  101.         rc=result
  102.         IF rc=1 then DO
  103.             pp_GetDialog 0
  104.             Start_O=result
  105.             End_O=result        
  106.         END
  107.     END
  108.     END
  109.  
  110.     if R=-8 then DO
  111.     IF Anim=1 then DO
  112.         pp_DialogInit 150 80 "*SIZE*%*" 2
  113.             pp_Integer 0 60 5 50 16 "Start" 1 Start_size
  114.             pp_Integer 1 60 25 50 16 "End" 1 End_size
  115.         pp_Dialog
  116.         rc=result
  117.         IF rc=1 then DO
  118.             pp_GetDialog 0
  119.             Start_size=result
  120.             pp_GetDialog 1
  121.             End_size=result    
  122.         END            
  123.     END
  124.     ELSE DO
  125.         pp_DialogInit 150 55 "*SIZE*" 1
  126.         pp_Integer 0 60 5 50 16 "Size*%" 1 Start_S
  127.         pp_Dialog
  128.         rc=result
  129.         IF rc=1 then DO
  130.             pp_GetDialog 0
  131.             Start_S=result
  132.             End_S=result        
  133.         END
  134.     END
  135.     END
  136.  
  137.     if R=-5 then DO
  138.     if Anim=1 then DO
  139.         pp_DialogInit 150 80 "*ROT*X*" 2
  140.             pp_Integer 0 60 5 50 16 "Start" 1 Start_rotx
  141.             pp_Integer 1 60 25 50 16 "End" 1 End_rotx
  142.         pp_Dialog
  143.         rc=result
  144.         IF rc=1 then DO
  145.             pp_GetDialog 0
  146.             Start_rotx=result
  147.             pp_GetDialog 1
  148.             End_rotx=result        
  149.         END            
  150.     END
  151.     ELSE DO
  152.         pp_DialogInit 150 55 "*ROT*X*" 1
  153.         pp_Integer 0 60 5 50 16 "RotX" 1 Start_rotx
  154.         pp_Dialog
  155.         rc=result
  156.         IF rc=1 then DO
  157.             pp_GetDialog 0
  158.             Start_rotx=result
  159.             End_rotx=result        
  160.         END
  161.     END
  162.     END
  163.  
  164.     if R=-6 then DO
  165.     IF Anim=1 then DO
  166.         pp_DialogInit 150 80 "*ROT*Y*" 2
  167.             pp_Integer 0 60 5 50 16 "Start" 1 Start_roty
  168.             pp_Integer 1 60 25 50 16 "End" 1 End_roty
  169.         pp_Dialog
  170.         rc=result
  171.         IF rc=1 then DO
  172.             pp_GetDialog 0
  173.             Start_roty=result
  174.             pp_GetDialog 1
  175.             End_roty=result        
  176.         END            
  177.     END
  178.     ELSE DO
  179.         pp_DialogInit 150 55 "*ROT*Y*" 1
  180.         pp_Integer 0 60 5 50 16 "RotY" 1 Start_roty
  181.         pp_Dialog
  182.         rc=result
  183.         IF rc=1 then DO
  184.             pp_GetDialog 0
  185.             Start_roty=result
  186.             End_roty=result        
  187.         END
  188.     END
  189.     END
  190.  
  191.     if R=-7 then DO
  192.     IF Anim=1 then DO
  193.         pp_DialogInit 150 80 "*ROT*Z*" 2
  194.             pp_Integer 0 60 5 50 16 "Start" 1 Start_rotz
  195.             pp_Integer 1 60 25 50 16 "End" 1 End_rotz
  196.         pp_Dialog
  197.         rc=result
  198.         IF rc=1 then DO
  199.             pp_GetDialog 0
  200.             Start_rotz=result
  201.             pp_GetDialog 1
  202.             End_rotz=result        
  203.         END            
  204.     END
  205.     ELSE DO
  206.         pp_DialogInit 150 55 "*ROT*Z*" 1
  207.         pp_Integer 0 60 5 50 16 "RotZ" 1 Start_rotz
  208.         pp_Dialog
  209.         rc=result
  210.         IF rc=1 then DO
  211.             pp_GetDialog 0
  212.             Start_rotz=result
  213.             End_rotz=result        
  214.         END
  215.     END
  216.     END
  217.  
  218.  
  219.     if R=-2 then DO
  220.         pp_DialogInit 150 80 "*FRAME*" 2
  221.             pp_Integer 0 60 5 50 16 "Start" 1 Start_Frame
  222.             pp_Integer 1 60 25 50 16 "End" 1 End_Frame
  223.         pp_Dialog
  224.         rc=result
  225.         IF rc=1 then DO
  226.             pp_GetDialog 0
  227.             Start_Frame=result
  228.  
  229.             pp_GetDialog 1
  230.             End_Frame=result
  231.  
  232.             IF End_Frame>Total_Frame THEN DO
  233.                 End_Frame=Total_Frame
  234.             END
  235.  
  236.             IF Start_Frame>End_Frame THEN DO
  237.                 Start_Frame=1
  238.             END
  239.  
  240.         END            
  241.     END
  242.  
  243. END
  244.  
  245.     if R=0 then DO
  246.         pp_PermitRefresh
  247.         EXIT
  248.     END    
  249.  
  250.     IF Anim=0 then DO
  251.         pp_UpdateUndo
  252.         pp_3DPrep 200 200 Start_rotx Start_roty-90 Start_rotz
  253.         IF Start_O<100 then DO
  254.             pp_EffectOn
  255.             pp_Trans Start_O
  256.             CALL Grid(Start_Shearx,Start_Sheary,Bw,Bh,Cx,Cy)
  257.             pp_EffectOff
  258.         END
  259.         ELSE DO
  260.             CALL Grid(Start_Shearx,Start_Sheary,Bw,Bh,Cx,Cy)
  261.         END
  262.     END
  263.     ELSE DO
  264.         pp_CountFrames
  265.         IF result<2 then do
  266.             pp_Warn 'Make*an*Anim*first.'
  267.             EXIT
  268.         END
  269.  
  270.         pp_GetWidth
  271.         W=result
  272.  
  273.         pp_GetHeight
  274.         H=result
  275.  
  276.         HX=Bw/2
  277.         HY=Bh/2
  278.  
  279.         Start_X=Cx
  280.         End_X=Cx
  281.         Start_Y=Cy
  282.         End_Y=Cy
  283.  
  284.         IF Path=1 then DO
  285.             IF Type=0 then DO
  286.                 Start_X=HX*-1
  287.             END
  288.             ELSE DO
  289.                 End_X=HX*-1
  290.             END
  291.         END
  292.  
  293.         IF Path=2 then DO
  294.             IF Type=0 then DO
  295.                 Start_X=W+HX
  296.             END
  297.             ELSE DO
  298.                 End_X=W+HX
  299.             END
  300.         END
  301.  
  302.         IF Path=3 then DO
  303.             IF Type=0 then DO
  304.                 Start_Y=HY*-1
  305.             END
  306.             ELSE DO
  307.                 End_Y=HY*-1
  308.             END
  309.         END
  310.  
  311.         IF Path=4 then DO
  312.             IF Type=0 then DO
  313.                 Start_Y=H+HY
  314.             END
  315.             ELSE DO
  316.                 End_Y=H+HY
  317.             END
  318.         END
  319.  
  320.         step=(End_Frame-Start_Frame)
  321.  
  322.         Step_rotx=(End_rotx-Start_rotx)/Step
  323.         Step_roty=(End_roty-Start_roty)/Step
  324.         Step_rotz=(End_rotz-Start_rotz)/Step
  325.         Step_Size=(End_Size-Start_Size)/Step
  326.         Step_O=(End_O-Start_O)/Step
  327.  
  328.         Step_X=(End_X-Start_X)/Step
  329.         Step_Y=(End_Y-Start_Y)/Step
  330.     
  331.  
  332.         DO i=Start_Frame to End_Frame
  333.  
  334.             pp_GotoFrame i
  335.  
  336.             rotx=trunc(Start_rotx+Step_rotx*(i-Start_Frame)+0.5,0)
  337.             roty=trunc(Start_roty+Step_roty*(i-Start_Frame)+0.5,0)
  338.             rotz=trunc(Start_rotz+Step_rotz*(i-Start_Frame)+0.5,0)
  339.             Size=trunc(Start_Size+Step_Size*(i-Start_Frame)+0.5,0)
  340.             O=trunc(Start_O+Step_O*(i-Start_Frame)+0.5,0)
  341.             X=trunc(Start_X+Step_X*(i-Start_Frame)+0.5,0)
  342.             Y=trunc(Start_Y+Step_Y*(i-Start_Frame)+0.5,0)
  343.  
  344.             Sizex=trunc((Bw*Size)/100,0)
  345.             Sizey=trunc((Bh*Size)/100,0)
  346.  
  347.             pp_3DPrep 200 200 rotx roty-90 rotz
  348.  
  349.             IF O<100 then DO
  350.                 pp_EffectOn
  351.                 pp_Trans O
  352.                 CALL Grid(Start_Shearx,Start_Sheary,Sizex,Sizey,X,Y)                
  353.                 pp_EffectOff
  354.             END
  355.             ELSE DO
  356.                 CALL Grid(Start_Shearx,Start_Sheary,Sizex,Sizey,X,Y)
  357.             END
  358.         
  359.         END
  360.  
  361.     END
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374. EXIT
  375.  
  376.  
  377. Grid: PROCEDURE
  378.  
  379.     XX=ARG(1)
  380.     YY=ARG(2)
  381.     W=ARG(3)
  382.     H=ARG(4)
  383.     Cx=ARG(5)
  384.     Cy=ARG(6)
  385.     
  386.   t1=W/XX
  387.   t2=H/YY
  388.  
  389.   i=0
  390.     DO j=0 to XX
  391.  
  392.         Dx=i-W/2
  393.         Dy=0
  394.         Dz=-1*H/2
  395.  
  396.         pp_3Dto2D Dx Dy Dz Cx Cy
  397.         pp_3DGetx
  398.         x.1=result
  399.         pp_3DGety
  400.         y.1=result
  401.  
  402.         Dx=i-W/2
  403.         Dy=0
  404.         Dz=t2*YY-H/2
  405.  
  406.         pp_3Dto2D Dx Dy Dz Cx Cy
  407.         pp_3DGetx
  408.         x.2=result
  409.         pp_3DGety
  410.         y.2=result
  411.  
  412.     pp_Line x.1 y.1 x.2 y.2
  413.  
  414.     i=i+t1
  415.     END
  416.  
  417.  
  418.     i=0
  419.     DO j=0 to YY
  420.  
  421.         Dx=-1*W/2
  422.         Dy=0
  423.         Dz=i-H/2
  424.  
  425.         pp_3Dto2D Dx Dy Dz Cx Cy
  426.         pp_3DGetx
  427.         x.1=result
  428.         pp_3DGety
  429.         y.1=result
  430.  
  431.         Dx=t1*XX-W/2
  432.         Dy=0
  433.         Dz=i-H/2
  434.         
  435.         pp_3Dto2D Dx Dy Dz Cx Cy
  436.         pp_3DGetx
  437.         x.2=result
  438.         pp_3DGety
  439.         y.2=result
  440.  
  441.     pp_Line x.1 y.1 x.2 y.2
  442.  
  443.     i=i+t2
  444.  
  445.     END
  446.  
  447. RETURN
  448.  
  449.  
  450.